<template>
	<page-meta :page-style="'overflow:'+(isFansPop?'hidden':'visible')"></page-meta>
	<view class="groupactiveform">
		<block v-if="showGroupactiveinfo">
			<view class="fansmeeting_form_box" style="margin-top: 0;">
				<view class="fansmeeting_form_topbk_box">
					<image class="fansmeeting_form_topbk" :src="onlinePic+'fansmeeting/form_bg_new.png'"
						mode="widthFix">
					</image>
				</view>
				<view style="margin-top: 30%;">
					<view v-for="(item,index) in group_arr" :key="index" v-if="group_status==0?index==0:true"
						style="padding-bottom:30rpx;">
						<view v-if="group_status==1" class="fans_num_box" style="margin-bottom: -20rpx;">
							<view class="flex-1 f-14 f-w" style="padding: 30rpx 0;" @click="showFansTeamInfo(index)">
								粉丝/车主(团体票，第{{index+1}}位)</view>
							<view class="pd-30" @click="showFansTeamInfo(index)">
								<image v-if="item.showInfo==1" class="fans_num_arrow"
									:src="onlinePic+'fansmeeting/arrow_down.png'"></image>
								<image v-else class="fans_num_arrow" :src="onlinePic+'fansmeeting/arrow_up.png'">
								</image>
							</view>
						</view>
						<block v-if="item.showInfo==1">
							<view class="groupmanage_input_box">
								<view class="display_flex">
									<view class="mr-5" style="min-width: 100rpx;">姓名</view>
									<input class="flex-1" v-model="item.name" maxlength="8" placeholder="您的姓名" />
								</view>
							</view>
							<view class="groupmanage_input_box">
								<view class="display_flex">
									<view class="mr-5" style="min-width: 100rpx;">手机号</view>
									<input class="flex-1" type="number" v-model="item.mobile" maxlength="11"
										placeholder="您的手机号" />
								</view>
							</view>
							<view class="groupmanage_input_box">
								<view class="display_flex">
									<view class="mr-5" style="min-width: 100rpx;">车型</view>
									<uni-data-select class="flex-1" v-model="item.car_series" :localdata="seriesList"
										:clear="false" placeholder="您的车型"></uni-data-select>
								</view>
							</view>
							<view class="f-11 ml-15 mt-5 c-999999">{{auditinfo.car_model_tips}}</view>
							<view class="groupmanage_input_box" v-if="item.car_series=='其他'">
								<view class="display_flex">
									<view class="mr-5" style="min-width: 100rpx;">车型</view>
									<input class="flex-1" v-model="item.car_series_other" maxlength="12"
										placeholder="您的车型版本" />
								</view>
							</view>
							<view class="groupmanage_input_box" v-if="item.car_series!='无车'">
								<view class="display_flex">
									<view class="mr-5" style="min-width: 100rpx;">车牌号</view>
									<input class="flex-1" v-model="item.car_number" maxlength="8" placeholder="您的车牌号" />
								</view>
							</view>
							<view class="groupmanage_input_box" v-if="item.car_series!='无车'">
								<view class="mr-5">爱车照片</view>
								<image v-if="item.pic" class="cars_img" style="height: 325rpx;" :src="picUrl+item.pic"
									mode="aspectFill" @click="uploadFansCarImg(index)">
								</image>
								<view v-else class="cars_bkimg_box" @click="uploadFansCarImg(index)">
									<image class="cars_bkimg" :src="onlinePic+'cars_bk.png'" mode="widthFix"></image>
									<view class="cars_bkimg_text_box">
										<image class="cars_camera_img" :src="onlinePic+'cars_camera.png'"></image>
										<view class="mt-5 f-11 text-c">请上传一张您的爱车照片</view>
										<view class="mt-5 f-11 text-c" style="color: #C92359;">请上传车牌清晰可见的照片,否则无法通过活动审核!
										</view>
									</view>
								</view>
							</view>
							<view class="groupmanage_man_num_input_box">
								<view class="display_flex" style="justify-content: space-between;">
									<view class="mr-5" style="min-width: 100rpx;">随行人数</view>
									<uni-section type="line" padding>
										<uni-number-box :min="1" :max="6" v-model="item.man_num" />
									</uni-section>
								</view>
							</view>
							<view class="groupmanage_input_box">
								<view class="mr-5">活动环节预选</view>
								<view class="mt-10">
									<uni-row :gutter="30">
										<uni-col v-for="(itemd,indexd) in projectslist" :key="itemd.id" :span="8">
											<view
												:class="item.project_type==itemd.id?'project_type_cell_on':'project_type_cell'">
												<view :class="item.project_type==itemd.id?'text-c':'c-999999 text-c'">
													<view>{{itemd.name}}</view>
													<view>￥{{itemd.price}}</view>
													<view v-if="itemd.tips" class="c-red f-11">{{itemd.tips}}</view>
												</view>
												<image v-if="itemd.is_paid==1" class="projects_pay_icon"
													:src="onlinePic+'fansmeeting/projects_pay_icon.png'"></image>
												<image v-if="item.project_type==itemd.id" class="projects_on_icon"
													:src="onlinePic+'fansmeeting/projects_on.png'"></image>
											</view>
											<view class="project_type_content">{{itemd.content}}</view>
										</uni-col>
									</uni-row>
								</view>
								<view v-if="item.project_type==3||item.project_type==2" class="agremment_box"
									style="margin-bottom: 0;margin-top: 20rpx;">
									<image v-if="item.isAgreeSafety" class="login_checkbox"
										:src="onlinePic+'checkbox_on.png'">
									</image>
									<image v-else class="login_checkbox" :src="onlinePic+'checkbox.png'">
									</image>
									<span class="agremment_text">我已阅读并同意</span>
									<span @click="goAgreement(auditinfo.agreement_id)" class="agremment_text"
										style="color: #33a1ff;">《{{auditinfo.agreement_name}}》</span>
								</view>
							</view>
							<view class="groupmanage_input_box" v-if="item.project_type==3||item.project_type==2">
								<view class="display_flex">
									<view class="mr-5" style="min-width: 100rpx;">身份证号</view>
									<input class="flex-1" v-model="item.id_card" maxlength="18" type="idcard"
										placeholder="注:身份证号码用于参加活动购买保险" />
								</view>
							</view>

						</block>
					</view>
					<!-- <view v-if="group_status==1" class="add_fans_btn_box">
					<view class="add_fans_btn" @click="addFans"><uni-icons type="plusempty" size="13"
							color="#ffffff"></uni-icons>添加粉丝</view>
				</view> -->
					<view class="fansmeeting_form_bottom_box" :style="'padding-bottom:'+ bottomSafeArea +'px;'">
						<view class="f-3 f-w ml-15 mr-15 mb-15">预选购票详情</view>
						<view class="bottom_ticket_cell">
							<view v-for="item in listWithCounts" :key="item.name" v-if="item.num>0"
								class="display_flex f-12 mt-5">
								<view class="flex-1">{{item.name}}</view>
								<view>x{{item.num}}</view>
							</view>
						</view>
						<view class="fansmeeting_form_submit_btn" @click="submitFansActiveForm">提交信息</view>
					</view>
				</view>
			</view>
		</block>
		<view class="fansmeeting_share_box" v-if="showShareTimeImg">
			<image style="width: 100%;" :src="onlinePic+'fansmeeting/fansmeeting_share_zh.jpg'" mode="widthFix"></image>
		</view>
		<view v-if="isFansPop" class="guide_mask_box" @click="closePopup"></view>
		<view class="fansmeeting_pop_box" v-if="isFansPop">
			<image class="pop_top_img" :src="picUrl+popImg" mode="widthFix"></image>
			<view class="fansmeeting_pop_content_box">
				<view class="f-15 text-c" v-if="popTitle">{{popTitle}}</view>
				<view class="fansmeeting_pop_content">
					<text>{{popContent}}</text>
				</view>
				<view class="pd-20">
					<view v-if="popType==1&&showSubmitBtn==1" class="fansmeeting_pop_btn" @click="closeClubPopup">
						{{popBtn}}
					</view>
					<view v-if="popType==2&&showSubmitBtn==1" class="fansmeeting_pop_btn" @click="closeProjectsPopup">
						{{popBtn}}
					</view>
					<view v-if="popType==3&&showSubmitBtn==1" class="fansmeeting_pop_btn" @click="closeSubmitPopup">
						{{popBtn}}
					</view>
					<view v-if="showSubmitBtn==2" class="fansmeeting_pop_btn_def">{{popBtn}}({{popTime}}s)</view>
				</view>
			</view>
			<view v-if="popType==1" class="pop_close_icon_box">
				<uni-icons class="pop_close_icon" @click="closePopup" type="close" color="#ffffff"
					size="50"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getClubCarSeriesAll,
		getGroupActiveInfo,
		noticeTemplate,
		getUserGroupActiveAuditInfo,
		editUserGroupActiveAudit,
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				info: '',
				auditinfo: '',
				club_id: '',
				huodong_id: '',
				huodong_club_id: '',
				car_series: '',
				projectslist: [],
				seriesList: [],
				modelList: [],
				group_status: 0,
				is_club_user: '',
				club_user_status: '',
				group_arr: [],
				isSubmit: true,
				listWithCounts: [],
				isFansPop: false,
				popImg: '',
				popTitle: '',
				popContent: '',
				popBtn: '',
				popTime: '',
				popTitle1: '',
				popContent1: '',
				popBtn1: '',
				popTime1: '',
				formIndex: 0,
				popType: 0,
				lastContent: 1,
				showSubmitBtn: 2,
				channel: '',
				showGroupactiveinfo: false,
				showShareTimeImg: false,
				picUrl: app.globalData.picUrl,
				onlinePic: app.globalData.onlinePic,
				safeBottom: uni.getSystemInfoSync().safeAreaInsets.bottom > 0 ? true : false,
				pageSafeArea: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets
					.bottom + 140 : 150,
				bottomSafeArea: uni.getSystemInfoSync().safeAreaInsets.bottom ? uni.getSystemInfoSync().safeAreaInsets
					.bottom : 15
			};
		},
		onShow() {
			if (!uni.getStorageSync('access_token')) {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			} else {
				this.userinfo = uni.getStorageSync('userinfo')
				getUserGroupActiveAuditInfo({
					huodong_id: this.huodong_id,
					channel: this.channel ? this.channel : ''
				}).then(res => {
					if (res.state == 1) {
						this.is_club_user = res.data.info.is_club_user
						this.club_user_status = res.data.info.club_user_status ? res.data.info.club_user_status :
							res.data.info.is_club_user == 1 ? 1 : 2
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			}
			if (uni.getStorageSync('onload')) {
				this.getGroupActiveInfo()
				this.getUserGroupActiveAuditInfo()
				uni.removeStorage({
					key: 'onload'
				})
			}
			uni.hideShareMenu({
				menus: ['shareAppMessage', 'shareTimeline']
			})
		},
		onLoad(options) {
			console.log('auditform↓↓↓↓↓↓')
			console.log(options)
			this.huodong_id = options.huodong_id ? options.huodong_id : ''
			this.huodong_club_id = options.club_id ? options.club_id : ''
			this.channel = options.channel ? options.channel : ''
			if (uni.getStorageSync('access_token')) {
				this.getGroupActiveInfo()
				this.getUserGroupActiveAuditInfo()
				this.getClubCarSeriesAll()
			}
			uni.removeStorage({
				key: 'activeForm'
			})
			if (uni.getStorageSync('Appoptions').scene == 1154) {
				this.showShareTimeImg = true
			} else if (uni.getStorageSync('Appoptions').scene == 1155) {
				uni.reLaunch({
					url: '/pages/group/groupactiveinfo?huodong_id=' + this.huodong_id +
						'&club_id=' + this
						.huodong_club_id + '&channel=' + this.channel,
				})
			} else {
				this.showShareTimeImg = false
			}
		},
		methods: {
			getGroupActiveInfo() {
				getGroupActiveInfo({
					huodong_id: this.huodong_id
				}).then(res => {
					if (res.state == 1) {
						this.info = res.data.info
						this.club_id = res.data.info.club_id
						var params = {
							event_code: '修改报名信息',
							path: 'pages/group/groupactiveinfo',
							event_id: this.huodong_id,
							title: res.data.info.title,
							source_page: '',
							value: this.channel ? this.channel : '',
						}
						app.BurialPoint(params)

					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			getUserGroupActiveAuditInfo() {
				getUserGroupActiveAuditInfo({
					huodong_id: this.huodong_id,
					channel: this.channel ? this.channel : ''
				}).then(res => {
					if (res.state == 1) {
						this.projectslist = res.data.info.festival_project_popup_arr
						this.group_status = res.data.info.group_status
						this.auditinfo = res.data.info
						this.is_club_user = res.data.info.is_club_user
						this.club_user_status = res.data.info.club_user_status ? res.data.info.club_user_status :
							res.data.info.is_club_user == 1 ? 1 : 2
						this.huodong_join_id = res.data.info.huodong_join_id ? res.data.info.huodong_join_id : 0
						this.popImg = res.data.info.festival_popup_img
						if (res.data.info.group_arr.length == 0) {
							var obj = {
								showInfo: 1,
								name: res.data.info.name,
								mobile: res.data.info.mobile,
								car_series: res.data.info.car_series,
								car_series_other: res.data.info.car_series_other,
								pic: res.data.info.pic,
								car_number: res.data.info.car_number,
								man_num: res.data.info.man_num,
								project_type: res.data.info.project_type,
								id_card: res.data.info.id_card,
								isAgreeSafety: res.data.info.id_card ? true : false
							}
							this.group_arr.push(obj)
						} else {
							var list = res.data.info.group_arr
							this.group_arr = list.map(item => ({
								...item,
								showInfo: 1,
								isAgreeSafety: item.id_card ? true : false
							}));

						}

						this.huodong_join_id = res.data.info.huodong_join_id ? res.data.info.huodong_join_id : 0
						var projectTypeCounts = this.countProjectTypes(this.group_arr);
						this.listWithCounts = this.projectslist.map(item => ({
							name: item.name,
							num: projectTypeCounts[item.id] || 0 // 如果id在projectTypeCounts中不存在，则num为0  
						}));
						this.showGroupactiveinfo = true
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			getClubCarSeriesAll() {
				getClubCarSeriesAll().then(res => {
					if (res.state == 1) {
						this.seriesList = res.data.info
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			changeSeries() {
				var car_series = this.car_series
				var item = this.seriesList.find(function(item) {
					return item.value === car_series;
				});
				if (item) {
					this.modelList = item.model
				}
				this.car_model_version = ''
				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: this.huodong_id,
					title: '',
					source_page: '修改报名信息-选择车系',
					value: '',
				}
				app.BurialPoint(params)
			},
			changeClubUser(type) {
				if (this.is_club_user == 1) {
					this.club_user_status = type
				} else {
					this.popType = 1
					this.isFansPop = true
					this.popTitle = this.auditinfo.festival_popup_club_title
					this.popContent = this.auditinfo.festival_popup_club_content
					this.popBtn = this.auditinfo.festival_popup_button_name
					this.popTime = this.auditinfo.festival_popup_club_time
					var that = this
					if (that.popTime > 0) {
						var Interval = setInterval(function() {
							if (that.popTime > 1) {
								that.popTime = that.popTime - 1
							} else {
								that.showSubmitBtn = 1
								clearInterval(Interval)
							}
						}, 1000)
					} else {
						that.showSubmitBtn = 1
					}
				}

				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: type,
					title: '',
					source_page: '修改报名信息-切换是否是车友会成员',
					value: '',
				}
				app.BurialPoint(params)
			},
			// 选择购票类型
			changeTicketType(type, index) {
				this.group_status = type
				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: type,
					title: '',
					source_page: '修改报名信息-切换购票类型',
					value: '',
				}
				app.BurialPoint(params)
			},
			addFans() {
				var obj = {
					id: 0,
					name: '',
					mobile: '',
					car_series: '',
					car_series_other: '',
					pic: '',
					car_number: '',
					man_num: 0,
					project_type: '',
					id_card: '',
					showInfo: 1,
					isAgreeSafety: false,
				}
				this.group_arr.push(obj)
				this.query = uni.createSelectorQuery().in(this);
				this.query.selectViewport().scrollOffset().exec(res => {
					var scrollTop = res[0].scrollTop + 392
					uni.pageScrollTo({
						scrollTop: scrollTop,
						duration: 300
					});
				});
				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: '',
					title: '',
					source_page: '修改报名信息-添加粉丝',
					value: '',
				}
				app.BurialPoint(params)
			},
			delForm(index) {
				var that = this
				uni.showModal({
					content: '确定删除吗？',
					confirmText: '删除',
					cancelText: "取消",
					success: function(res) {
						if (res.confirm) {
							that.group_arr.splice(index, 1)
							var projectTypeCounts = that.countProjectTypes(that.group_arr);
							that.listWithCounts = that.projectslist.map(item => ({
								name: item.name,
								num: projectTypeCounts[item.id] ||
									0 // 如果id在projectTypeCounts中不存在，则num为0  
							}));
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			uploadFansCarImg(index) {
				var that = this
				uni.chooseMedia({
					count: 1,
					mediaType: ['image'],
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: function(res) {
						var tempFilePaths = res.tempFiles
						uni.uploadFile({
							url: app.globalData.uploadUrl,
							filePath: tempFilePaths[0].tempFilePath,
							name: 'img',
							success: (uploadFileRes) => {
								var picdata = JSON.parse(uploadFileRes.data);
								that.group_arr[index].pic = picdata.data.img
							}
						});
					}
				});
				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: that.huodong_id,
					title: '',
					source_page: '修改报名信息-上传爱车靓照',
					value: '',
				}
				app.BurialPoint(params)
			},
			submitFansActiveForm() {
				var that = this
				if (uni.getStorageSync('access_token')) {
					if (that.isSubmit) {
						that.isSubmit = false
						if (that.group_status == 0) {
							if (that.group_arr[0].name == '') {
								uni.showToast({
									title: '请输入姓名',
									mask: true,
									icon: 'none',
									duration: 1500
								})
								that.isSubmit = true
								return false;
							}
							if (that.group_arr[0].mobile == '') {
								uni.showToast({
									title: '请输入手机号',
									mask: true,
									icon: 'none',
									duration: 1500
								})
								that.isSubmit = true
								return false;
							} else {
								if (!(/^1[3456789]\d{9}$/.test(that.group_arr[0].mobile))) {
									uni.showToast({
										title: '请输入正确的手机号',
										icon: 'none',
										duration: 1500
									});
									that.isSubmit = true
									return false;
								}
							}

							if (that.group_arr[0].car_series == '') {
								uni.showToast({
									title: '请选择车型',
									mask: true,
									icon: 'none',
									duration: 1500
								})
								that.isSubmit = true
								return false;
							}
							if (that.group_arr[0].car_series == '其他') {
								if (that.group_arr[0].car_series_other == '') {
									uni.showToast({
										title: '请输入车型',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									return false;
								}
							}
							if (that.group_arr[0].car_series != '无车' && that.group_arr[0].car_number == '') {
								uni.showToast({
									title: '请输入车牌号',
									mask: true,
									icon: 'none',
									duration: 1500
								})
								that.isSubmit = true
								return false;
							}
							if (that.group_arr[0].car_series != '无车' && that.group_arr[0].pic == '') {
								uni.showToast({
									title: '请上传爱车照片',
									mask: true,
									icon: 'none',
									duration: 1500
								})
								that.isSubmit = true
								return false;
							}

							if (that.group_arr[0].project_type == '') {
								uni.showToast({
									title: '请选择活动环节',
									mask: true,
									icon: 'none',
									duration: 1500
								})
								that.isSubmit = true
								return false;
							}
							if (that.group_arr[0].project_type == 2 || that.group_arr[0].project_type == 3) {
								if (that.group_arr[0].id_card == '') {
									uni.showToast({
										title: '请输入身份证号',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									return false;
								} else {
									if (!(/^(\d{6})(18|19|20)?(\d{2})(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X|x)$/
											.test(
												that.group_arr[0].id_card))) {
										uni.showToast({
											title: '请输入正确的身份证号',
											mask: true,
											icon: 'none',
											duration: 1500
										})
										that.isSubmit = true
										return false;
									}
								}
							}
						} else {
							that.group_arr.forEach((item, index) => {
								if (!item.name) {
									uni.showToast({
										title: '请输入姓名',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请输入姓名')
									return false;
								} else if (!item.mobile) {
									uni.showToast({
										title: '请输入手机号',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请输入手机号')
									return false;
								} else if (!(/^1[3456789]\d{9}$/.test(item.mobile))) {
									uni.showToast({
										title: '请输入正确的手机号',
										icon: 'none',
										duration: 1500
									});
									that.isSubmit = true
									throw new Error('请输入正确的手机号')
									return false;
								} else if (!item.car_series) {
									uni.showToast({
										title: '请选择车型',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请选择车型')
									return false;
								} else if (item.car_series == '其他' && !item.car_series_other) {
									uni.showToast({
										title: '请输入车型',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请输入车型')
									return false;
								} else if (item.car_series != '无车' && !item.car_number) {
									uni.showToast({
										title: '请输入车牌号',
										mask: true,
										icon: 'none',
										duration: 1500
									})

									that.isSubmit = true
									throw new Error('请输入车牌号')
									return false;
								} else if (item.car_series != '无车' && item.car_number.length < 7) {
									uni.showToast({
										title: '请输入正确的车牌号',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请输入正确的车牌号')
									return false;
								} else if (item.car_series != '无车' && !item.pic) {
									uni.showToast({
										title: '请上传爱车照片',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请上传爱车照片')
									return false;
								}
								else if (!item.project_type) {
									uni.showToast({
										title: '请选择活动环节',
										mask: true,
										icon: 'none',
										duration: 1500
									})
									that.isSubmit = true
									throw new Error('请选择活动环节')
									return false;
								} else if (item.project_type == 2 || item.project_type == 3) {
									if (!item.id_card) {
										uni.showToast({
											title: '请输入身份证号',
											mask: true,
											icon: 'none',
											duration: 1500
										})
										that.isSubmit = true
										throw new Error('请输入身份证号')
										return false;
									} else if (!(
											/^(\d{6})(18|19|20)?(\d{2})(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X|x)$/
											.test(item.id_card))) {
										uni.showToast({
											title: '请输入正确的身份证号',
											mask: true,
											icon: 'none',
											duration: 1500
										})
										that.isSubmit = true
										throw new Error('请输入正确的身份证号')
										return false;
									}
								}

							});
						}
						uni.requestSubscribeMessage({
							tmplIds: ['rcQkW8wcn38CXiWvvjjQgFx3SscCmBguRKsd3N6Ip1U'],
							success: function(res) {
								noticeTemplate({
									template_type: 5 //4:车友会；5:活动报名结果；6:活动创建结果
								}).then(res => {
									if (res.state == 1) {
										var params = {
											event_code: '修改报名信息',
											path: 'pages/group/groupactiveform',
											event_id: that.auditinfo
												.huodong_id,
											title: '',
											source_page: '修改报名信息-允许消息通知',
											value: '',
										}
										app.BurialPoint(params)
									} else {
										that.isSubmit = true
										var params = {
											event_code: '修改报名信息',
											path: 'pages/group/groupactiveform',
											event_id: that.auditinfo
												.huodong_id,
											title: '',
											source_page: '修改报名信息-拒绝消息通知',
											value: '',
										}
										app.BurialPoint(params)
									}
								})
							},
							fail: function(e) {
								console.log(e)
							}
						})
						that.popType = 3
						that.isFansPop = true
						that.popTitle = that.auditinfo.update_popup_title
						that.popContent = that.auditinfo.update_popup_content
						that.popBtn = that.auditinfo.update_popup_button_name
						that.popTime = that.auditinfo.update_popup_time
						if (that.popTime > 0) {
							var Interval = setInterval(function() {
								if (that.popTime > 1) {
									that.popTime = that.popTime - 1
								} else {
									that.showSubmitBtn = 1
									clearInterval(Interval)
								}
							}, 1000)
						} else {
							that.showSubmitBtn = 1
						}

					}
				} else {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				}
			},
			editUserGroupActiveAudit(form) {
				var that = this
				editUserGroupActiveAudit(form).then(res => {
					if (res.state == 1) {
						uni.showToast({
							title: '提交成功',
							mask: true,
							icon: 'success',
							duration: 1500
						})
						that.isSubmit = true
						uni.setStorage({
							data: true,
							key: 'onload'
						})
						setTimeout(function() {
							uni.reLaunch({
								url: '/pages/group/groupactiveinfo?huodong_id=' + that
									.huodong_id +
									'&club_id=' + that
									.huodong_club_id +
									'&channel=' + that
									.channel
							})
							that.name = ''
							that.mobile = ''
							that.pic = ''
							that.is_pet = ''
							that.pet_num = ''
							that.pet_type = ''
							that.is_child = ''
							that.child_num = ''
							that.child_age = ''
							that.age = ''
							that.sex = ''
							that.car_series = ''
							that.car_model_version = ''
							that.desc = ''
							that.province = ''
							that.city = ''
							that.area = ''
							that.city_text = ''
							that.purchase_time = ''
							that.isAgree = false
							that.group_arr = [{
								name: '',
								mobile: '',
								car_series: '',
								car_series_other: '',
								pic: '',
								car_number: '',
								man_num: 0,
								project_type: '',
								id_card: '',
								showInfo: 1,
								isAgreeSafety: false,
							}]
						}, 1500)
					} else {
						that.isSubmit = true
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: that.huodong_id,
					title: '',
					source_page: '修改报名信息-提交信息',
					value: '',
				}
				app.BurialPoint(params)
			},
			showFansTeamInfo(index) {
				this.group_arr[index].showInfo = this.group_arr[index].showInfo == 1 ? 2 : 1
			},
			changeProjects(type, index, indexd) {
				this.formIndex = index
				this.group_arr[index].project_type = type
				this.popTitle = this.projectslist[indexd].popup_title
				this.popTitle1 = this.projectslist[indexd].popup_protocol_title
				this.popContent = this.projectslist[indexd].popup_content
				this.popContent1 = this.projectslist[indexd].popup_protocol
				this.popBtn = this.projectslist[indexd].festival_popup_button_name
				this.popBtn1 = this.projectslist[indexd].popup_protocol_button_name
				this.popTime = this.projectslist[indexd].popup_time
				this.popTime1 = this.projectslist[indexd].popup_protocol_time
				if (this.projectslist[indexd].popup_protocol) {
					this.lastContent = 2
				} else {
					this.lastContent = 1
				}

				var projectTypeCounts = this.countProjectTypes(this.group_arr);
				this.listWithCounts = this.projectslist.map(item => ({
					name: item.name,
					num: projectTypeCounts[item.id] || 0 // 如果id在projectTypeCounts中不存在，则num为0  
				}));
				console.log(this.listWithCounts);
				this.popType = 2
				this.isFansPop = true
				var that = this
				if (that.popTime > 0) {
					var Interval = setInterval(function() {
						if (that.popTime > 1) {
							that.popTime = that.popTime - 1
						} else {
							that.showSubmitBtn = 1
							clearInterval(Interval)
						}
					}, 1000)
				} else {
					that.showSubmitBtn = 1
				}
				var params = {
					event_code: '修改报名信息',
					path: 'pages/group/groupactiveform',
					event_id: that.auditinfo
						.huodong_id,
					title: '',
					source_page: '修改报名信息-切换活动环节',
					value: type,
				}
				app.BurialPoint(params)
			},
			countProjectTypes(list2) {
				// 使用reduce来创建一个对象，其属性是project_type，值是出现次数  
				return list2.reduce((acc, item) => {
					acc[item.project_type] = (acc[item.project_type] || 0) + 1;
					return acc;
				}, {});
			},
			numberInputResult(e) {
				console.log(e.carNumber)
				this.group_arr[e.dataIndex].car_number = e.carNumber.replace(/\s/g, '')
			},
			showFansPop(type) {
				this.popType = 1
				this.isFansPop = true
				this.popTitle = this.auditinfo.festival_popup_club_title
				this.popContent = this.auditinfo.festival_popup_club_content
				this.popBtn = this.auditinfo.festival_popup_button_name
				this.popTime = this.auditinfo.festival_popup_club_time
				var that = this
				if (that.popTime > 0) {
					var Interval = setInterval(function() {
						if (that.popTime > 1) {
							that.popTime = that.popTime - 1
						} else {
							that.showSubmitBtn = 1
							clearInterval(Interval)
						}
					}, 1000)
				} else {
					that.showSubmitBtn = 1
				}
			},
			closeClubPopup() {
				var that = this
				uni.requestSubscribeMessage({
					tmplIds: ['kwpV3YHFx0TJQXZGE1dmXyPuKB5KEhhxSols7MgJYKk'],
					success: function(res) {
						console.log(res)
						noticeTemplate({
							template_type: 4 //4:车友会；5:活动报名结果；6:活动创建结果
						}).then(res => {
							if (res.state == 1) {
								that.popTime = 5
								that.isFansPop = false
								that.showSubmitBtn = 2
								that.popTitle = ''
								that.popContent = ''
								that.popBtn = ''
								that.popTime = ''
								uni.navigateTo({
									url: '/pages/group/groupjoin'
								})
							} else {

							}
						})
					},
					fail: function(e) {
						console.log('==fail==')
						console.log(e)
					}
				})
			},
			closeProjectsPopup() {
				this.popTime = 5
				if (this.lastContent == 1) {
					this.isFansPop = false
					this.showSubmitBtn = 2
					this.group_arr[this.formIndex].isAgreeSafety = true
					this.popTitle = ''
					this.popContent = ''
					this.popContent1 = ''
					this.popBtn = ''
					this.popTime = ''
				} else {
					this.showSubmitBtn = 2
					this.popTitle = this.popTitle1
					this.popContent = this.popContent1
					this.popBtn = this.popBtn1
					this.popTime = this.popTime1
					var that = this
					if (this.popTime > 0) {
						var Interval = setInterval(function() {
							if (that.popTime > 1) {
								that.popTime = that.popTime - 1
							} else {
								that.showSubmitBtn = 1
								that.lastContent = 1
								clearInterval(Interval)
							}
						}, 1000)
					} else {
						that.showSubmitBtn = 1
						that.lastContent = 1
					}
				}
			},
			closeSubmitPopup() {
				var that = this
				if (that.group_status == 0) {
					var form = {
						huodong_join_id: that.auditinfo.huodong_join_id,
						channel: that.channel,
						club_id: that.club_id,
						huodong_id: that
							.huodong_id,
						huodong_club_id: that
							.huodong_club_id,
						group_status: that
							.group_status,
						huodong_join_id: that
							.huodong_join_id,
						name: that.group_arr[0]
							.name,
						mobile: that.group_arr[0]
							.mobile,
						car_series: that.group_arr[
							0].car_series,
						car_series_other: that
							.group_arr[0]
							.car_series_other,
						car_number: that.group_arr[
							0].car_number,
						man_num: that.group_arr[0]
							.man_num,
						pic: that.group_arr[0].pic,
						club_user_status: that
							.club_user_status,
						id_card: that.group_arr[0]
							.id_card,
					}
				} else {

					var form = {
						huodong_join_id: that.auditinfo.huodong_join_id,
						channel: that.channel,
						club_id: that.club_id,
						huodong_id: that
							.huodong_id,
						huodong_club_id: that
							.huodong_club_id,
						huodong_join_id: that
							.huodong_join_id,
						group_status: that
							.group_status,
						club_user_status: that
							.club_user_status,
						group_arr: that.group_arr
					}
				}
				that.isFansPop = false
				that.showSubmitBtn = 2
				that.popTitle = ''
				that.popContent = ''
				that.popBtn = ''
				that.popTime = ''
				that.editUserGroupActiveAudit(form)
			},
			closePopup() {
				if (this.popType == 1 || this.popType == 4) {
					this.popTime = 5
					this.isFansPop = false
					this.showSubmitBtn = 2
					this.popTitle = ''
					this.popContent = ''
					this.popBtn = ''
					this.popTime = ''
				}
			},
			goAgreement(id) {
				this.isAgree = true
				uni.navigateTo({
					url: '/pages/agreement/agreement?scene=' + id + '&club_id=' + this.info.club_id
				})
			},
		}
	}
</script>

<style lang="scss">
	.groupactiveform {


		.add_fans_btn_box {
			display: flex;
			align-items: center;
			justify-content: center;
			padding-top: 30rpx;
		}

		.add_fans_btn {
			width: 100%;
			padding: 30rpx 0;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #ffffff;
			font-size: 26rpx;
			border-radius: 8rpx;
			background-color: #000000;
		}

		.fansmeeting_form_del {
			color: #FFFFFF;
			font-size: 20rpx;
			padding: 5rpx 10rpx;
			text-align: center;
			background-color: red;
			border-radius: 8rpx;
		}

		.next_step_btn {
			display: flex;
			align-items: center;
			justify-content: center;
			color: #ffffff;
			padding: 25rpx 0;
			margin: 30rpx 0 30rpx 0;
			border-radius: 8rpx;
			background-color: #00A0DC;
		}

		.fansmeeting_form_bottom_box {
			margin-top: 30rpx;
			padding-top: 30rpx;
			border-top: 1rpx solid #E9E9E9;

			.bottom_ticket_cell {
				padding: 30rpx;
				border-top: 1rpx solid #E9E9E9;
			}

			.fansmeeting_form_submit_btn {
				font-size: 30rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100%;
				color: #ffffff;
				padding: 30rpx 0;
				border-radius: 8rpx;
				background-color: #00A0DC;
			}
		}

		.agremment_box {
			margin-bottom: 180rpx;

			.login_checkbox {
				width: 26rpx;
				height: 26rpx;
				vertical-align: middle;
			}

			.agremment_text {
				color: #191919;
				font-size: 24rpx;
				margin-left: 10rpx;
				vertical-align: middle;
			}
		}
	}
</style>